from django.contrib import admin

from polls.models import Teacher, Subject, User


class BaseModelAdmin(admin.ModelAdmin):
    ordering = ('no',)


class SubjectModelAdmin(BaseModelAdmin):
    list_display = ('no', 'name', 'intro', 'is_hot')


class TeacherModelAdmin(BaseModelAdmin):
    list_display = ('no', 'name', 'sex', 'birth', 'short_intro',
                    'good_count', 'bad_count', 'subject')
    search_fields = ('name', 'intro')


class UserModelAdmin(BaseModelAdmin):
    list_display = ('no', 'username', 'tel', 'reg_date', 'last_visit', 'vote_count')
    search_fields = ('username', 'tel')


admin.site.register(Subject, SubjectModelAdmin)
admin.site.register(Teacher, TeacherModelAdmin)
admin.site.register(User, UserModelAdmin)
